home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Samples / SampleCode / Tumbler and Podium / Tumbler_windows.c < prev    next >
Encoding:
Text File  |  1995-11-13  |  2.8 KB  |  130 lines  |  [TEXT/MPS ]

  1. //
  2. //        windows.c
  3. //
  4. //        Window handling routines.
  5. //        
  6. //
  7. //        Author:        Nick Thompson & Pablo Fernicola, with thanks to the QuickDraw 3D team
  8. //
  9. //        Copyright © 1992-95 Apple Computer, Inc., All Rights Reserved
  10. //
  11. //
  12.  
  13.  
  14. #include "Tumbler_globals.h"
  15. #include "Tumbler_prototypes.h"
  16.  
  17. #include "Tumbler_windows.h"
  18. #include "Tumbler_camera.h"
  19. #include "Tumbler_offscreen.h"
  20.  
  21.  
  22. //
  23. //    UpdateWindow is called when an update event is received for a docuemnt
  24. //    window.
  25. //
  26.  
  27. void UpdateWindow(WindowPtr theWindow)
  28.  
  29. {
  30.     DocumentPtr    theDocument = GetDocumentFromWindow(theWindow) ;
  31.     GrafPtr        savedPort ;
  32.     
  33.     GetPort( &savedPort ) ;
  34.     if(theDocument!=nil) {
  35.         SetPort(theWindow);
  36.         
  37.         BeginUpdate(theWindow);
  38.     
  39. //        EraseRect(&theWindow->portRect);
  40.         DrawOffscreen(theDocument);
  41.         DrawOnscreen(theDocument);
  42.         DoDrawGrowIcon(theWindow);
  43.     
  44.         EndUpdate(theWindow);
  45.     }
  46.     SetPort( savedPort ) ;
  47. }
  48.  
  49.  
  50. //
  51. //    GrowDocumentWindow is called when the user clicks in the growRgn of a
  52. //    document window.
  53. //
  54.  
  55. void GrowDocumentWindow(WindowPtr theWindow, Point thePoint)
  56.  
  57. {    long        result;
  58.     Rect        sizeRect;
  59.     GrafPtr        savedPort ;
  60.  
  61. #ifdef PODIUM_APP
  62.     return ;
  63. #endif
  64.     
  65.     GetPort(&savedPort) ;
  66.     SetPort(theWindow) ;
  67.  
  68.     sizeRect = qd.screenBits.bounds;
  69.     
  70.     if ((result = GrowWindow(theWindow, thePoint, &sizeRect)) == 0)
  71.         return;
  72.         
  73.     SizeWindow(theWindow, LoWord(result), HiWord(result), false);
  74.     
  75.     EraseRect(&theWindow->portRect);
  76.     InvalRect(&theWindow->portRect);
  77.     
  78.     if( ((DocumentPtr ) ((WindowPeek) theWindow)->refCon)->documentGroup )
  79.         AdjustCamera((DocumentPtr ) ((WindowPeek) theWindow)->refCon,
  80.                         theWindow->portRect.right - theWindow->portRect.left,
  81.                         theWindow->portRect.bottom - theWindow->portRect.top);
  82.     
  83.     UpdateWindow(theWindow);
  84.  
  85.     SetPort(savedPort) ;
  86. }
  87.  
  88.  
  89. //-------------------------------------------------------------------------------
  90. //    DoDrawGrowIcon
  91. //
  92. //    Draw the grow icon. We do this in such a way that the scrollbar lines are
  93. //    not drawn. Normally, when the Toolbox routine DrawGrowIcon is called,
  94. //    vertical and horizontal lines are also drawn indicating where the
  95. //    scrollbars will be drawn. We don’t have scrollbars, so we don’t want those
  96. //    lines drawn. We avoid them by setting the clipping region of the window to
  97. //    include the grow box only. We then call DrawGrowIcon, and restore the old
  98. //    clipping region before returning.
  99.  
  100. void    DoDrawGrowIcon(WindowPtr theWindow)
  101. {
  102.     Rect        iconRect;
  103.     RgnHandle    oldClip;
  104.  
  105.     // this slows animation for demos down a lot
  106.     // probably should say something like
  107.     // if( gUsingHardware && theDocument->animate)
  108.     if(gUsingHardware) {
  109.         return ;
  110.     }
  111. #ifdef PODIUM_APP
  112.     return ;
  113. #endif
  114.  
  115.     SetPort(theWindow);
  116.     oldClip = NewRgn();
  117.     GetClip(oldClip);
  118.  
  119.     iconRect = theWindow->portRect;
  120.     iconRect.top = iconRect.bottom - 15;
  121.     iconRect.left = iconRect.right - 15;
  122.     ClipRect(&iconRect);
  123.  
  124.     PenNormal();
  125.     DrawGrowIcon(theWindow);
  126.  
  127.     SetClip(oldClip);
  128.     DisposeRgn(oldClip);
  129. }
  130.